//
//  HttpClientDataCacheManager.m
//  ITV
//
//  Created by inphase on 17/5/12.
//  Copyright © 2017年 inphase. All rights reserved.
//

#import "HttpClientDataCacheManager.h"
#import <MJExtension.h>

@implementation HttpClientDataCacheManager

+(void)load {

    NSString *cachePath = [[HttpClientDataCacheManager manager] httpClientDataPath];
    NSLog(@"缓存路径：%@",cachePath);
}


+(HttpClientDataCacheManager *)manager {
    static HttpClientDataCacheManager *instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[HttpClientDataCacheManager alloc]init];
    });
    
    return [instance copy];
}

-(id)copyWithZone:(NSZone *)zone {
    
    HttpClientDataCacheManager *cache = [[self class] allocWithZone:zone];
    
    return cache;

}

// 文件路径
-(NSString *) httpClientDataPath {

    NSString *cachePath = [NSSearchPathForDirectoriesInDomains (NSCachesDirectory , NSUserDomainMask , YES) firstObject];
    return cachePath;
}

-(void)saveObject:(NSObject *)object forKey:(NSString *)key {
    // 先将对象转换成字典
    NSDictionary *dictionary = object.mj_keyValues;
    NSError *error = nil;
    NSData *data = [NSJSONSerialization dataWithJSONObject:dictionary options:NSJSONWritingPrettyPrinted error:&error];
    NSAssert(!error, @"JSON 数据格式错误");
    NSString *jsonString = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
    // 写文件
    NSString *path = [NSString stringWithFormat:@"%@/%@",[self httpClientDataPath],key];
    
    
}

-(id)objectForKey:(NSString *)key withClass:(Class)classType {

    return nil;
}





@end
